/**
项目JS主入口
以依赖Layui的layer和form模块为例
**/    
layui.define(function(exports){
	var util={
			getQueryString:function(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return unescape(r[2]);
				return null;
			},
			getYear:function(){
				return  new Date().getFullYear();
			},
			getMonth:function(){
				return  new Date().getMonth(); 
			},
			encodeURI:function(key){
				return encodeURI(key);
			},
			decodeURI:function(key){
				return decodeURI(key);
			},
		    checkPhone:function(phone){
		    	if(phone == ''){
		    		layer.msg('请输入手机号!',{icon:2,time:1000});
					return false;
				}
				var cellphone = /^(1[0-9])[0-9]{9}$/;
				if(phone.length < 11){
		    		layer.msg('请输入正确的手机号!',{icon:2,time:1000});
					return false;
				}
				if(!cellphone.test(phone)) {
					var note = '['+phone+']'+'手机号码不正确，请重新输入！';
		    		layer.msg(note,{icon:2,time:1000});
			     	return false;
			    }
			    return true;
		    },
		    uniqueArray:function(array, key){
			    var result = [array[0]];
			    for(var i = 1; i < array.length; i++){
			        var item = array[i];
			        var repeat = false;
			        for (var j = 0; j < result.length; j++) {
			            if (item[key] == result[j][key]) {
			                repeat = true;
			                break;
			            }
			        }
			        if (!repeat) {
			            result.push(item);
			        }
			    }
			    return result;
			}
			
	}
	exports('Zutil',util); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});